/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.ms.filecenter.model.entity;

import jakarta.persistence.*;
import lombok.*;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

/**
 * hallele_ms_filecenter
 *
 * @author anle5
 * @since 2024/9/15 20:55
 */
@Getter
@Setter
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "fc_api_log")
public class ApiLogEntity implements Serializable {
    @Serial
    private static final long serialVersionUID = 1147030514801650665L;

    /**
     * 身份唯一标识
     * 生成策略: 从表key_generator中读取
     * name: TableGenerator唯一标识
     * pkColumnName：生成策略所对应键值的名称
     * pkColumnValue：键当前所生成的值，它的值将会随着每次创建累加
     * initialValue: 初始值
     * allocationSize: 递增至
     */
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "ApiLogEntity")
    @TableGenerator(name = "ApiLogEntity",
            table = "key_generator",
            pkColumnName = "gen_name",
            valueColumnName = "gen_value",
            pkColumnValue = "fc_api_log",
            initialValue = 1,
            allocationSize = 1
    )
    @Column(name = "id")
    private Long id;

    /**
     * 微服务名字
     */
    @Column(name = "app_name")
    private String appName;

    /**
     * 接口ID
     */
    @Column(name = "api_id")
    private String apiId;

    /**
     * 请求id
     */
    @Column(name = "trance_id")
    private String tranceId;

    /**
     * ip
     */
    @Column(name = "ip")
    private String ip;

    /**
     * ip归属地
     */
    @Column(name = "ip_place")
    private String ipPlace;

    /**
     * 设备信息
     */
    @Column(name = "client_info")
    private String clientInfo;

    /**
     * 发起者
     */
    @Column(name = "initiator")
    private Long initiator;

    /**
     * 请求
     */
    @Column(name = "request")
    private String request;

    /**
     * 响应
     */
    @Column(name = "response")
    private String response;

    /**
     * 请求开始时间
     */
    @Column(name = "request_start_time")
    private Date requestStartTime;

    /**
     * 请求结束时间
     */
    @Column(name = "request_end_time")
    private Date requestEndTime;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private Date createTime;

    /**
     * 错误码
     */
    @Column(name = "msg_code")
    private String msgCode;

    /**
     * 异常信息
     */
    @Column(name = "msg_desc")
    private String msgDesc;
}
